package cn.kgc.spring.factory;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @author: mosin
 * @version: v1.0  2022/10/12
 * 自定义工厂对象获取复杂类型的对象
 * 静态工厂
 *  1.定义一个普通类
 *  2.再类中定义一个普通静态方法 返回值是想要获取的bean类型
 *  3.声明
 *   <bean id="connectionFactoryBean3" class="cn.kgc.spring.factory.ConnectionFactoryBean3" factory-method="getConnection"></bean>
 *
 */
public class ConnectionFactoryBean3 {

    public static Connection getConnection() throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql:///java2216", "root", "root");
        return connection;
    }

}
